package org.ruizhijie.config;

import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

public class BluetoochCardQueue {
	private static Map<String,ConcurrentLinkedQueue<String>> ques = new HashMap<String, ConcurrentLinkedQueue<String>>();
	private static Queue<String> queueTcp = new ConcurrentLinkedQueue<String>();
	
	public static void putQues(String key,ConcurrentLinkedQueue<String> v){
		ques.put(key, v);
	}
	
	public synchronized static ConcurrentLinkedQueue<String> getQueue(String com){
		return ques.get(com);
	}
	
	public synchronized static String poll(String com){
		return ques.get(com).poll();
	}
	
	public synchronized static void offer(String com,String val){
		ques.get(com).offer(val);
		if (ques.get(com).size()>1000)ques.get(com).poll();
	}
	
	public synchronized static int size(String com){
		return ques.get(com).size();
	}
	
	
	public static String pollTcp() {
		return queueTcp.poll();
	}
	
	public static void offerTcp(String str) {
		queueTcp.offer(str);
		if (queueTcp.size()>1000)queueTcp.poll();
	}
	
	public static int sizeTcp() {
		return queueTcp.size();
	}
}
